package abstract_factory


var DefaultFactoryRegistry = newFactoryRegistry()


type IFactoryRegistry interface {
	Set(vendor string, factory ISmartFactory)
	Get(vendor string) ISmartFactory
}

type tSimpleFactoryRegistry struct {
	mFactoryMap map[string]ISmartFactory
}

func newFactoryRegistry() IFactoryRegistry {
	return &tSimpleFactoryRegistry{
		mFactoryMap: make(map[string]ISmartFactory, 0),
	}
}

func (me *tSimpleFactoryRegistry) Set(vendor string, factory ISmartFactory) {
	me.mFactoryMap[vendor] = factory
}

func (me *tSimpleFactoryRegistry) Get(vendor string) ISmartFactory {
	it,ok := me.mFactoryMap[vendor]
	if ok {
		return it
	}
	return nil
}